#!/usr/bin/env python3

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, LogInfo
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node


def generate_launch_description():
    return LaunchDescription([
        # 声明参数
        DeclareLaunchArgument(
            'namespace',
            default_value='',
            description='节点命名空间'
        ),
        
        DeclareLaunchArgument(
            'use_sim_time',
            default_value='false',
            description='是否使用仿真时间'
        ),
        
        # 启动信息
        LogInfo(
            msg="=== 启动自动飞行任务 ==="
        ),
        
        LogInfo(
            msg="任务序列："
        ),
        
        LogInfo(
            msg="1. 等待5秒"
        ),
        
        LogInfo(
            msg="2. 起飞到0.8m高度"
        ),
        
        LogInfo(
            msg="3. 飞到位置(2, 0)"
        ),
        
        LogInfo(
            msg="4. 降低到0.5m高度"
        ),
        
        LogInfo(
            msg="5. 飞回初始位置(0, 0)"
        ),
        
        LogInfo(
            msg="6. 降低到0.2m高度"
        ),
        
        LogInfo(
            msg="=== 任务即将开始 ==="
        ),
        
        # 自动飞行任务节点
        Node(
            package='pb2025_sentry_nav',
            executable='auto_flight_mission.py',
            name='auto_flight_mission',
            namespace=LaunchConfiguration('namespace'),
            parameters=[{
                'use_sim_time': LaunchConfiguration('use_sim_time')
            }],
            output='screen',
            emulate_tty=True
        ),
    ]) 